package com.ld.cool_library.http;

import com.example.cool_core.config.PublicConfig;
import com.example.cool_core.http.CoolHttpObserver;

public abstract class CoolResObserver<T extends HttpResModel> extends CoolHttpObserver<T> {
    public CoolResObserver(PublicConfig mPublicConfig) {
        super(mPublicConfig);
    }

    public CoolResObserver(Object tag, PublicConfig mPublicConfig) {
        super(tag, mPublicConfig);
    }

    public CoolResObserver(Object tag) {
        super(tag);
    }

    public CoolResObserver() {
    }

    @Override
    protected void HttpSuccess(T t) {
        if (t.getReason().equals("Success")) {
            showContent();
            if (mPublicConfig != null) {
                mPublicConfig.setHttpSuccess(true);
            }
            onSuccess(t);
        } else {
            HttpError(new Throwable(t.getReason()));
        }
    }

    protected abstract void onSuccess(T t);
}
